package com.xpc.test.controller;

import com.xpc.starter.annotation.DataPermission;
import com.xpc.test.bean.FileInfo;
import com.xpc.test.queryobj.FileInfoQueryObj;
import com.xpc.test.service.FileInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能描述：文件controller
 *
 * @author xpc on 2024/4/2 9:19
 */
@RestController
@RequestMapping("file")
@Slf4j
@CrossOrigin
@DataPermission(column = "creator")
public class FileController {
    private final FileInfoService fileInfoService;

    public FileController(FileInfoService fileInfoService) {
        this.fileInfoService = fileInfoService;
    }

    @RequestMapping("list")
//    @DataPermission(column = "creator")
    public List<FileInfo> list(@RequestBody FileInfoQueryObj queryObj) {
        return this.fileInfoService.list(queryObj.buildQuery());
    }

    @RequestMapping("authList")
    @DataPermission(column = "creator", table = "tui")
    public List<FileInfo> authList() {
        return this.fileInfoService.authList();
    }

    @RequestMapping("save")
    public void save(@RequestBody FileInfo fileInfo) {
        this.fileInfoService.save(fileInfo);
    }


}
